/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lvoddownloader;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JProgressBar;
import javax.swing.JSlider;
import javax.swing.plaf.basic.BasicProgressBarUI;

/**
 *
 *  @author wcss
 */
public class LProgressBarUI  extends BasicProgressBarUI
{
     public void paint(Graphics g, JComponent c)
     {         
         Graphics2D g2d = (Graphics2D)g;
         g2d.clearRect(0,0, (int)g.getClipBounds().getWidth(), (int)g.getClipBounds().getHeight());
         g2d.setColor(this.progressBar.getBackground());
         g2d.fillRect(0,0, (int)g.getClipBounds().getWidth(), (int)g.getClipBounds().getHeight());
         ImageIcon progress = new ImageIcon(LProgressBarUI.class.getResource("/UIImages/top/Download.png"));
         ImageIcon progressbg = new ImageIcon(LProgressBarUI.class.getResource("/UIImages/top/DownloadBG.png"));
         g2d.drawImage(progressbg.getImage(), 0, (((int)g.getClipBounds().getHeight() - 7) / 2), ((int)g.getClipBounds().getWidth() / 10) * 10, 7, null);
         int nowProgressWidth = 0;
         System.out.println(this.progressBar.getValue());
         if (this.progressBar.getValue() > 0 && this.progressBar.getValue() < 10)
         {
            nowProgressWidth = ((int)g.getClipBounds().getWidth() / 10) * 2; 
         }else
         {
            nowProgressWidth = ((int)g.getClipBounds().getWidth() / 10) * ((this.progressBar.getValue() / 10) + (this.progressBar.getValue() % 10>0?1:0));
         }
         g2d.drawImage(progress.getImage(), 0,(((int)g.getClipBounds().getHeight() - 7) / 2) , nowProgressWidth , 7,null);
     }
}
